package com.legrand.www.module.worker.controller;

import com.legrand.www.module.exception.exception.CustomizeException;
import com.legrand.www.module.worker.aop.RolePermission;
import com.legrand.www.module.worker.entity.Teacher;
import com.legrand.www.module.worker.feign.UserFeignServer;
import com.legrand.www.module.worker.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/api/worker")
public class TeacherController {

    @Autowired
    private TeacherService teacherService;

    @Autowired
    private UserFeignServer userFeignServer;

    @RequestMapping("/getTeacher")
    @ResponseBody
    public Teacher getTeacher() {
        return teacherService.getTeacher();
    }

    @RequestMapping("/getUserName")
    @ResponseBody
    public String getUserName() {
        Integer a = 1;
        Integer b = 0;
        //throw new CustomizeException("111","sdfsd");
        Integer c = a / b;
        return userFeignServer.getUserName();
    }

    @RequestMapping("/rightTest")
    @RolePermission(roles = { "worker"})
    @ResponseBody
    public String rightTest() {
        return "调用成功，拥有该权限";
    }
}
